package com.animal.service.impl;

import com.animal.entity.AnAnimal;
import com.animal.entity.AnDonation;
import com.animal.mapper.AnAnimalMapper;
import com.animal.mapper.AnDonationMapper;
import com.animal.mapper.AnUserMapper;
import com.animal.service.AnDonationService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author animal
 * @since 2022-02-08
 */
@Service
public class AnDonationServiceImpl extends ServiceImpl<AnDonationMapper, AnDonation> implements AnDonationService {
@Autowired
AnDonationMapper anDonationMapper;
@Autowired
    AnAnimalMapper anAnimalMapper;
@Autowired
    AnUserMapper anUserMapper;
    @Override
    public List<AnDonation> findAll(int size, int current) {
        Page<AnDonation> userPages = new Page<>(size,current);
        Page<AnDonation> userPagess=  anDonationMapper.selectPage(userPages,null);
        List<AnDonation> list=userPagess.getRecords();

        for(AnDonation a:list){
            a.setAnUser(anUserMapper.selectById(a.getUserId()));
            a.setAnimal(anAnimalMapper.selectById(a.getAnId()));
        }
return list;
    }
}
